<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>作业</title>
    <script src="vue.js"></script>
    <script src="vue-router.js"></script>
    <script src="axios.min.js"></script>

    <style>
        ul {
            list-style-type: none;
        }

        li {
            float: left;
            width: 150px;
        }

        li a {
            text-decoration: none;
        }

        .show {
            clear: both;
            margin-top: 50px;
        }

        .itemStyle {
            border: 1px dashed black;
            border-radius: 15px;
            padding: 10px;
            width: 200px;
            height: 280px;
            text-align: center;
            float: left;
            margin-right: 50px;
            margin-bottom: 50px;
            box-shadow: 10px 10px 5px dimgray;
            background: -webkit-gradient(linear, left top, right bottom, color-stop(0%, green), color-stop(100%, yellow));
        }

        .itemFont {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            line-height: 32px;
        }
    </style>
</head>

<body>


    <div id="app1">
        <div>
            <ul>
                <li style="font-weight: 900;font-size: large;">精品推荐</li>
                <li v-for="woniu in woniuList">
                    <router-link :to="woniu.path">{{woniu.wname}}</router-link>
                </li>
            </ul>
        </div>
        <div class="show">
            <!--承载展示数据 -->
            <router-view></router-view>
        </div><br>

        <div v-for="woniu in woniuList">
            <template :id="woniu.tid" v-for="course in woniu.courses">
                <div class="itemStyle">
                    <div>
                        <img :src="course.pic" alt="" width="200px" height="120px">
                    </div>

                    <div>
                        <div class="itemFont">
                            {{course.title}}
                        </div>
                        <div class="itemFont">
                            {{course.desc}}
                        </div>
                        <div class="itemFont" style="text-align: right;color: firebrick;">{{course.type}}</div>
                        <div>
                            <img :src="course.headimg" width="22px" height="22px">
                            <span>{{course.tname}}</span>
                            <span>{{course.count}}</span>
                        </div>
                    </div>
                </div>
            </template>
        </div>
    </div>

</body>

</html>
<script>

    var vm1 = new Vue({
        el: "#app1",
        data: {
            url: "http://localhost:8080/wonius",
            woniuList: []
        },
        created() {
            axios({
                url: this.url,
                method: "GET"
            }).then(res => {
                this.woniuList = res.data.data.woniuList;
                console.log(res);
            })
        },
        router: new VueRouter({
            routes: [
                {
                    path: "/zhibo",
                    component: {
                        template: "#t1"
                    },
                },
                {
                    path: "/wangke",
                    component: {
                        template: "#t2"
                    },
                },
                {
                    path: "/free",
                    component: {
                        template: "#t3"
                    },
                },
                {
                    path: "/suitang",
                    component: {
                        template: "#t4"
                    },
                },
                {
                    path: "/project",
                    component: {
                        template: "#t5"
                    },
                },
                {
                    path: "/health",
                    component: {
                        template: "#t6"
                    },
                }
            ],

        }),
        // 默认路径
        beforeCreate: function () {
            this.$router.push("/zhuan");
        },
    });

</script>